from django.contrib import admin

from .models import * 

admin.site.site_header = '管理系统'  # 设置header
class MenusIntroInline(admin.TabularInline):
    model = MenusIntro
    extra = 0 

class OrderDetailInline(admin.TabularInline):
    model = OrderDetail
    extra = 0 

class PersonnelAdmin(admin.ModelAdmin):
    search_fields = ('order_no','service_date','customer_mobile')
    list_display = ('name','sex','birthday','address','work_item','tags', 'create_date')
    
class OrderListAdmin(admin.ModelAdmin):
    ordering = ['order_no']
    search_fields = ('order_no','service_date','customer_mobile')
    list_display = ('order_no','order_price','customer_name','customer_mobile','customer_address','order_status','service_date', 'create_date')
    inlines = [
        OrderDetailInline,
    ] 
    
class ServicePriceAdmin(admin.ModelAdmin):
    ordering = ['service_id']
    search_fields = ['service_id']
    list_display = ('id', 'service_id', 'service_price', 'service_qr', 'update_date', 'create_date')
    
class MenusAdmin(admin.ModelAdmin):
    ordering = ['sort']
    search_fields = ['name']
    list_display = ('id', 'name', 'icon', 'page_url', 'menu_type', 'sort')
    inlines = [
        MenusIntroInline,
    ]

class MenusIntroAdmin(admin.ModelAdmin):
    ordering = ['menu_id', 'sort']
    search_fields = ['content']
    list_display = ('id', 'content', 'type', 'menu_id', 'sort', 'style', 'create_date')
    
class SystemAdAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'url', 'image', 'sort', 'status',  'create_date')


admin.site.register(Menus, MenusAdmin)
#admin.site.register(Menus)
admin.site.register(MenusIntro, MenusIntroAdmin)
#admin.site.register(ThirdLogin)
admin.site.register(SystemAd, SystemAdAdmin)
admin.site.register(ServicePrice, ServicePriceAdmin)
admin.site.register(OrderList, OrderListAdmin)
admin.site.register(Personnel, PersonnelAdmin)


